def Simple(n):
    k=2
    while k*k<=n and n%k!=0:
        k+=1
    return (k*k>n)

    
s=input()
r=s.split(' ')
if r[0]=='zero' or (len(r)<3 or len(r)>3):
    print("Wrong input")
else:
    d = {'zero':0,'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9}
    number=0
    i=100
    for digit in r:    
        number+=(d[digit])*i
        i/=10

    num=int(number)
    num1=num
    num2=num
    num3=0
    num4=0

    if(Simple(num) == True):
        print(num)
    else:
        while (Simple(num1) == False):
            num1 -= 1
        num3=num1    
        while (Simple(num2) == False):
            num2 += 1
        num4=num2
    
        if(abs(num - num3) <= abs(num-num4)):
            print(num3)
        elif (abs(num - num3) > abs(num-num4)):
            print(num4)
